
<%@page import="ll.sms.util.SmsUtil"%><%@ page language="java" import="java.util.*,ll.sms.web.*,ll.sms.pojo.*,ll.sms.web.*"  pageEncoding="UTF-8"%>
<%@page import="ll.sms.util.SmsConstant"%>
<%@page import="java.sql.Timestamp"%>
<%@page import="ll.sms.db.Transaction"%>
<%@page import="ll.sms.factory.BeanFactory"%>
<%@page import="ll.sms.dao.SmsAdminDAO"%>
<%@page import="ll.sms.dao.BaseDAO"%>
<%@page import="org.apache.commons.dbutils.DbUtils;"%>
<%
try{
SmsAdmin smsAdmin = new SmsAdmin();
String pass=ParamUtils.getParameter(request,"apwd");
String repass=ParamUtils.getParameter(request,"reapwd");
if(pass==null || pass.trim().equals("") || !pass.equals(repass)){
	out.print( "{success:false,errors:{msg:'密码不匹配..'}}");
	return;
}

RequestUtils.populate(smsAdmin,request);
smsAdmin.setAregisttime(new Timestamp( new Date().getTime()));
smsAdmin.setAid(SmsUtil.getPrimaryKey());
smsAdmin.setApwd(SmsUtil.encodePassword(smsAdmin.getApwd()));
//添加业务员
smsAdmin.setArank(SmsConstant.OPERATOR_TYPE);
Transaction.begin();
int i =((BaseDAO)BeanFactory.getBean(BaseDAO.class)).countByDistinct("sms_admin", "auname", smsAdmin.getAuname());
			if(i>=1){
				DbUtils.closeQuietly(ll.sms.db.Transaction.currentConnection());
				out.print( "{success:false,errors:{msg:'用户名已经被占用'}}");
				return;
			}
((SmsAdminDAO)BeanFactory.getBean(SmsAdminDAO.class)).saveAdmin(smsAdmin);
Transaction.commit();
out.print( "{success:false,errors:{msg:'添加操作员成功'}}");
}catch(Exception e){
	e.printStackTrace();
	out.print( "{success:false,errors:{msg:'添加失败！！'}}");
}
//out.print( "{success:true}");
%>
